package com.shop.loan.service.impl;


import com.shop.loan.redis.RedisCache;
import com.shop.loan.redis.RedisUtil;
import com.shop.loan.service.LoanSignService;
import com.shop.loan.util.LoanOrderUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Log4j2
@Service
public class LoanSignServiceImpl implements LoanSignService {

    @Resource
    RedisUtil redisUtil;

    @Resource
    LoanOrderUtil loanOrderUtil;

    @Override
    public void createSignContract() {
        Object orderIdObj = redisUtil.rpop(RedisCache.waitCreateContract);
        if (orderIdObj != null) {
            Long orderId = Long.parseLong(orderIdObj.toString());
            String result = loanOrderUtil.createSignContract(orderId, true);
            log.info("订单:{},生成电子签结果:{}", orderId, result);
        }
    }
}
